/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Controler.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author goum
 */
public class WindowGame extends JFrame {

    private JPanel tourpan = new JPanel();
    private JMenuBar menuBar = new JMenuBar();
    private JMenu menu1 = new JMenu("partie");
    private JMenuItem item1 = new JMenuItem("Nouvelle partie");
    private JMenuItem item2 = new JMenuItem("Quitter");
    private PlateauView plateau;
    private ScoreView score;
    private TourView tour;
    private NotificationErreurView notif;
    private Controler Controler;

    public WindowGame() {
        this.Controler = new Controler();
        this.plateau = new PlateauView(Controler);
        this.score = new ScoreView(Controler);
        this.tour = new TourView(Controler);
        this.tourpan.setBackground(Color.LIGHT_GRAY);
        this.tourpan.setPreferredSize(new Dimension(250, 800));
        this.tourpan.add(tour);

        this.notif = new NotificationErreurView(Controler);
        this.tourpan.add(notif);

        this.setTitle("Jeu de Dame");
        this.setSize(new Dimension(800, 720));
        this.setResizable(false);//empecher le redimennement
        this.setLocationRelativeTo(null);//posionner au centre
        //terminer le processuse lorsque clique sur fermer
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        //on ajoute l'ecran  de la bombe et icon et ecran du temps
        // dans le conteneur partieHaute




        //On définit le layout à utiliser sur le contentPane
        this.setLayout(new BorderLayout());


        //On ajoute le bouton au contentPane de la JFrame
        //Au centre

        this.getContentPane().add(tourpan, BorderLayout.EAST);
        this.getContentPane().add(score, BorderLayout.NORTH);
        this.getContentPane().add(plateau, BorderLayout.CENTER);


        //
        item1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                reinitialise();
            }
        });

        item2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                System.exit(0);
            }
        });

        this.menu1.add(item1);
        this.menu1.add(item2);
        this.menuBar.add(menu1);
        this.setJMenuBar(menuBar);
        this.setVisible(true);
    }

    public void reinitialise() {
        this.Controler = new Controler();
        this.plateau = new PlateauView(Controler);
        this.score = new ScoreView(Controler);
        this.tour = new TourView(Controler);
        this.tourpan.setBackground(Color.LIGHT_GRAY);
        this.tourpan.setPreferredSize(new Dimension(250, 800));
        this.tourpan.add(tour);

        this.notif = new NotificationErreurView(Controler);
        this.tourpan.add(notif);
        this.setLayout(new BorderLayout());

        this.getContentPane().add(tourpan, BorderLayout.EAST);
        this.getContentPane().add(score, BorderLayout.NORTH);
        this.getContentPane().add(plateau, BorderLayout.CENTER);
        this.setVisible(true);
    }
}
